﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TodoApp.BrandModel;
using TodoApp.Enum;
using TodoApp.TodoBrandDTO;
using Volo.Abp.Domain.Repositories;

namespace TodoApp
{
    /// <summary>
    ///  商品品牌 实现服务 接口 
    /// </summary>
   
    public class BrandService : Volo.Abp.Application.Services.ApplicationService, IBrandService
    {

        /// <summary>
        ///  注入 
        /// </summary>

        private readonly IRepository<TodoBrand, Guid> _todoBrands;
        public BrandService(IRepository<TodoBrand, Guid> todoBrands) {
            _todoBrands = todoBrands;
        }

        /// <summary>
        ///  删除 
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        
        public async Task DeleteAsync(Guid id)
        {
            await _todoBrands.DeleteAsync(id);
        }

        /// <summary>
        /// 显示 
        /// </summary>
        /// <returns></returns>

        public async Task<List<TodoBrandShowDTO>> GetListAsync()
        {
            var str = await _todoBrands.GetListAsync();
            return ObjectMapper.Map<List<TodoBrand>,List<TodoBrandShowDTO>>(str);
        }

        /// <summary>
        ///  添加 
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>

        public async Task<ShopStatus> InsertAsync(TodoBrandAddDTO model)
        {
            await _todoBrands.InsertAsync(ObjectMapper.Map<TodoBrandAddDTO,TodoBrand>(model));
            return ShopStatus.Succeed; 
        }

        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>

        public async Task<ShopStatus> UpdateAsync(TodoBrandShowDTO model)
        {
            await _todoBrands.UpdateAsync(ObjectMapper.Map<TodoBrandShowDTO , TodoBrand>(model));
            return ShopStatus.Succeed;
        }
    }
}
